//
// Created by bleedingfight on 2020/7/7.
//
#include "twoSum.h"
std::vector<int> twoSum(std::vector<int>& nums, int target){
    std::map<int,int>res;
    std::vector<int>result;
    std::map<int,int>map_index;
    for(int index = 0;index<nums.size();index++){
        map_index[nums[index]]=index;
        res[target-nums[index]]=-1;
    }
    for(int index=0;index<nums.size();index++){
        int temp = target-nums[index];
        if(map_index.count(temp)&&map_index[temp]!=index&&map_index[temp]!=-1){
            result.push_back(index);
            result.push_back(map_index[temp]);
            break;
        }
    }
    return result;
}
